<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        //第1种方法call(this,参数1,参数2,)
        // function Father(uname, age, sex) {
        //     this.uname = uname
        //     this.age = age
        //     this.sex = sex
        // }
        // function Son(uname, age, sex) {
        //     Father.call(this, uname, age, sex)
        // }
        // var son = new Son('刘德华', 18, '男')
        // console.log(son);
        //第2种方法apply(this,数组)Math.max不能接受数组形式
        // var arr = [1, 3, 6, 234, 45]
        // var min = Math.min.apply(Math, arr)
        // var max = Math.max.apply(Math, arr)
        // console.log(min);
        // console.log(max);
        //第2种方法bind不会被调用会重新创造一个形函数
        var o = {
            uname: '刘德华',
            age: 15
        }
        function add(x, y) {
            console.log(this);
            console.log(x + y);
        }
        var fn = add.bind(o, 4, 5)
        fn()
        console.log(fn);
    </script>
</body>

</html>